//
//  JRTXDiagramView.h
//  
//
//  Created by JIRENTIANXIANG on 6/21/15.
//
//

#import <UIKit/UIKit.h>
#import "JRTXDiagramViewConfiguration.h"
#import "JRTXDiagramDatum.h"
#import "JRTXDiagramDataDisplayMapper.h"

@interface JRTXDiagramViewLineStyle : NSObject

@property (copy,nonatomic) UIColor* color;
@property (assign,nonatomic) CGFloat segmentLength;
@property (assign,nonatomic) CGFloat gapLength;
@property (assign,nonatomic) CGFloat lineWidth;

+(JRTXDiagramViewLineStyle*)lineStyleWithColor:(UIColor*)color lineWidth:(CGFloat)lineWidth segmentLength:(CGFloat)segmentLength gapLength:(CGFloat)gapLength;

@end

@class JRTXDiagramView;

//-----------------------------------------------------------------------
// protocol-JRTXDiagramDataSource
//-----------------------------------------------------------------------
@protocol JRTXDiagramDataSource <NSObject>

@optional

-(NSInteger)numberOfXIndicesInDiagramView:(JRTXDiagramView*)diagramView;
-(NSInteger)numberOfYIndicesInDiagramView:(JRTXDiagramView*)diagramView;

-(NSNumber*)diagramView:(JRTXDiagramView*)diagramView valueForXIndex:(NSInteger)index;
-(NSNumber*)diagramView:(JRTXDiagramView*)diagramView valueForYIndex:(NSInteger)index;

-(UIView*)diagramView:(JRTXDiagramView*)diagramView viewForXIndex:(NSInteger)index;
-(UIView*)diagramView:(JRTXDiagramView *)diagramView viewForYIndex:(NSInteger)index;

-(NSInteger)numberOfXValuesInDiagramView:(JRTXDiagramView*)diagramView;
-(NSInteger)numberOfYValuesInDiagramView:(JRTXDiagramView *)diagramView;

-(JRTXDiagramViewLineStyle*)diagramView:(JRTXDiagramView*)diagramView lineStyleForXIndex:(NSInteger)index;
-(JRTXDiagramViewLineStyle*)diagramView:(JRTXDiagramView *)diagramView lineStyleForYIndex:(NSInteger)index;

@end
//-----------------------------------------------------------------------


@interface JRTXDiagramView : UIView

@property (strong,nonatomic) NSArray* diagramData;
@property (strong,nonatomic) JRTXDiagramDataDisplayMapper* mapper;
@property (weak,nonatomic) id<JRTXDiagramDataSource> dataSource;
@property (strong,nonatomic) JRTXDiagramViewConfiguration* configuration;
@property (assign,nonatomic) CGRect graphArea;

-(instancetype)initWithFrame:(CGRect)frame configuration:(JRTXDiagramViewConfiguration*)config;
-(void)updateDisplay;

@end
